package dfbz.homework1;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Test01 {
    public static void main(String[] args) {
        HashMap<String, String> map = new HashMap<>();
        map.put("黄晓明","杨颖");
        map.put("刘恺威","杨幂");
        map.put("abay","a1");//无需
        map.put("baby2","a2");
        map.put("黄晓明","a2");
        System.out.println(map);
        String s = map.get("黄晓明");
        System.out.println(s);//黄晓明  --s2
        String abay = map.remove("abay");//移除
        System.out.println(abay);//abay--a1
//        Iterator<Map.Entry<String, String>> iterator = map.entrySet().iterator();
//        while (iterator.hasNext()){
//            Map.Entry<String, String> next = iterator.next();
//            System.out.println(next.getKey()+"---"+next.getValue());
//        }
        Set<Map.Entry<String, String>> entries = map.entrySet();
        for (Map.Entry<String, String> entry : entries) {
            System.out.println(entry.getKey()+"--------"+entry.getValue());
        }
    }
}
